package com.multimedia.scala.euler

import scala.annotation.tailrec
/*
However, in 2004 there was found a massive non-Mersenne
prime which contains 2,357,207 digits: 28433*(2^7830457)+1.

Find the last ten digits of this prime number.
 */
object Asd97 {
    def main(args : Array[String]) : Unit = {
    	/* discrete potenciate */
    	@tailrec
    	def dp(x: Long = 28433, steps: Long = 7830457): Long = {
    	    if (steps==0) return x
    	    var str = x.toString()
    	    if (str.size>10) dp(2*(str.drop(str.size-10).toLong), steps-1)
    	    else dp(x * 2, steps - 1)
    	}

    	println(dp()+1)
    	//println("14907080704".drop(1))
    }
}
